package ru.efimmatytsin.tweeterella.converters;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import ru.efimmatytsin.tweeterella.entities.Tweet;
import ru.efimmatytsin.tweeterella.viewmodels.PostViewModel;
import ru.efimmatytsin.tweeterella.viewmodels.TweetViewModel;

/**
 * Created by Efim Matytsin on 22.02.15.
 */
@Component
public class PostViewModelConverter implements Converter<Tweet,PostViewModel> {

    @Autowired
    private TweetViewModelConverter converter;

    @Override
    public PostViewModel<TweetViewModel> convert(Tweet tweet) {
        PostViewModel<TweetViewModel> postViewModel = new PostViewModel<TweetViewModel>();
        postViewModel.setType("tweet");
        postViewModel.setItem(converter.convert(tweet));
        return postViewModel;
    }
}
